package com.xunji.user;


import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Author: xuqiang_imyours
 * @Date: 2025/6/5 11:32
 * @Description:
 **/
@EnableSwagger2
@SpringBootApplication(scanBasePackages = {"com.xunji.user"})
@MapperScan("com.xunji.user.mapper")
@Slf4j
public class UserApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext app = SpringApplication.run(UserApplication.class, args);
        Environment env = app.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        // 未配置默认空白
        if (path == null) {
            path = "";
        }
        // 未配置默认空白
        if (port == null) {
            port = "8080";
        }
        log.info("\n----------------------------------------------------------\n\t" +
                "项目启动成功，访问路径如下:\n\t" +
                "本地路径: http://localhost:" + port + path + "/\n\t" +
                "网络地址: http://" + ip + ":" + port + path + "/\n\t" +
                "接口地址: http://" + ip + ":" + port + path + "/swagger-ui.html\n\t" +
                //"API文档: http://" + ip + ":" + port + path + "/doc.html\n" +
                "----------------------------------------------------------");
    }
}
